{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "import re"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "file = \"20ad.csv\"\n",
    "df_20ad=pd.read_csv(file,header=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def getRepoInfo(repoUrl):\n",
    "  result = {}\n",
    "  pattern = r'^https://gitee\\.com/(?P<userName>[^/]*?)/(?P<repoName>[^/]+?)(\\.git)?$'\n",
    "  m = re.match(pattern, repoUrl,re.M)\n",
    "  if m:\n",
    "    # return m\n",
    "    result['userName'] = m.group('userName')\n",
    "    result['repoName'] = m.group('repoName')\n",
    "    return result\n",
    "  else:\n",
    "    return None"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_20ad['检验后']=df_20ad['仓库地址'].apply(getRepoInfo)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_20ad[[\"仓库地址\",\"检验后\"]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "print(df_20ad)"
   ]
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "3f8fbc23b2a41515b896703ff7f99b01c6e80255122fee80a9cf9349d3bdee5d"
  },
  "kernelspec": {
   "display_name": "Python 3.9.7 64-bit (system)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "name": "python",
   "version": "3.9.7"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
